package server.model.players.packets;

import server.model.players.Client;
import server.model.players.PacketType;


/**
 * Wear Item
 **/
public class WearItem implements PacketType {

	@Override
	public void processPacket(Client c, int packetType, int packetSize) {
		c.wearId = c.getInStream().readUnsignedWord();
		c.wearSlot = c.getInStream().readUnsignedWordA();
		c.interfaceId = c.getInStream().readUnsignedWordA();
		
		int oldCombatTimer = c.attackTimer;
		if (c.playerIndex > 0 || c.npcIndex > 0)
			c.getCombat().resetPlayerAttack();
                // start skillcapes
		if (c.wearId == 9747 || c.wearId == 9748) { //attack
                  if(c.getPA().getLevelForXP(c.playerXP[0]) < 99) {
                  c.sendMessage("You need an Attack level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9750 || c.wearId == 9751) { //strength
                  if(c.getPA().getLevelForXP(c.playerXP[2]) < 99) {
                  c.sendMessage("You need an Strength level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9753 || c.wearId == 9754) { //defence
                  if(c.getPA().getLevelForXP(c.playerXP[1]) < 99) {
                  c.sendMessage("You need an Defence level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9756 || c.wearId == 9757) { //ranging
                  if(c.getPA().getLevelForXP(c.playerXP[4]) < 99) {
                  c.sendMessage("You need an Range level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9759 || c.wearId == 9760) { //prayer
                  if(c.getPA().getLevelForXP(c.playerXP[5]) < 99) {
                  c.sendMessage("You need an Prayer level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9762 || c.wearId == 9763) { //magic
                  if(c.getPA().getLevelForXP(c.playerXP[6]) < 99) {
                  c.sendMessage("You need an Magic level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9765 || c.wearId == 9766) { //runecraft
                  if(c.getPA().getLevelForXP(c.playerXP[20]) < 99) {
                  c.sendMessage("You need an Runecrafting level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9768 || c.wearId == 9769) { //hitpoints
                  if(c.getPA().getLevelForXP(c.playerXP[3]) < 99) {
                  c.sendMessage("You need an Hitpoints level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9771 || c.wearId == 9772) { //agility 
                  if(c.getPA().getLevelForXP(c.playerXP[16]) < 99) {
                  c.sendMessage("You need an Agility level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9774 || c.wearId == 9775) { //herblore
                  if(c.getPA().getLevelForXP(c.playerXP[15]) < 99) {
                  c.sendMessage("You need an Herblore level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9777 || c.wearId == 9778) { //thieving
                  if(c.getPA().getLevelForXP(c.playerXP[17]) < 99) {
                  c.sendMessage("You need an Thieving level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9780 || c.wearId == 9781) { //crafting
                  if(c.getPA().getLevelForXP(c.playerXP[12]) < 99) {
                  c.sendMessage("You need an Crafting level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9783 || c.wearId == 9784) { //fletching
                  if(c.getPA().getLevelForXP(c.playerXP[9]) < 99) {
                  c.sendMessage("You need an Fletching level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9786 || c.wearId == 9787) { //slayer
                  if(c.getPA().getLevelForXP(c.playerXP[18]) < 99) {
                  c.sendMessage("You need an Slayer level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9792 || c.wearId == 9793) { //mining
                  if(c.getPA().getLevelForXP(c.playerXP[14]) < 99) {
                  c.sendMessage("You need an Mining level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9795 || c.wearId == 9796) { //Smithing
                  if(c.getPA().getLevelForXP(c.playerXP[13]) < 99) {
                  c.sendMessage("You need an Smithing level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9798 || c.wearId == 9799) { //Fishing
                  if(c.getPA().getLevelForXP(c.playerXP[10]) < 99) {
                  c.sendMessage("You need an Fishing level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9801 || c.wearId == 9802) { //Cooking
                  if(c.getPA().getLevelForXP(c.playerXP[7]) < 99) {
                  c.sendMessage("You need an Cooking level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9804 || c.wearId == 9805) { //Firemaking
                  if(c.getPA().getLevelForXP(c.playerXP[11]) < 99) {
                  c.sendMessage("You need an Firemaking level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9807 || c.wearId == 9808) { //Woodcutting
                  if(c.getPA().getLevelForXP(c.playerXP[8]) < 99) {
                  c.sendMessage("You need an Woodcutting level of 99.");
                  return;
                  }
                }
		if (c.wearId == 9810 || c.wearId == 9811) { //Farming
                  if(c.getPA().getLevelForXP(c.playerXP[19]) < 99) {
                  c.sendMessage("You need an Farming level of 99.");
                  return;
                  }
				} 
		//end skillcapes
		//start random items
		if (c.wearId == 15006) { //vls
                  if(c.getPA().getLevelForXP(c.playerXP[0]) < 78) {
                  c.sendMessage("You need an Attack level of 78.");
                  return;
                  } //end random items
                }
		if (c.wearId == 10887) { //anchor
                  if(c.getPA().getLevelForXP(c.playerXP[0]) < 50) {
                  c.sendMessage("You need an Attack level of 50.");
                  return;
                  }
                }
		if (c.wearId == 7449) { //meat tendy
                  if(c.getPA().getLevelForXP(c.playerXP[0]) < 60) {
                  c.sendMessage("You need an Attack level of 60.");
                  return;
                  }
                }
		if (c.wearId >= 5509 && c.wearId <= 5515) {
			int pouch = -1;
			int a = c.wearId;
			if (a == 5509)
				pouch = 0;
			if (a == 5510)
				pouch = 1;
			if (a == 5512)
				pouch = 2;
			if (a == 5514)
				pouch = 3;
			c.getPA().emptyPouch(pouch);
			return;
		}
			//c.attackTimer = oldCombatTimer;
		c.getItems().wearItem(c.wearId, c.wearSlot);
	}

}
